from schablonesk.logic.const_true import ConstTrue


class BranchesBlock(object):
    
    def __init__(self):
        self.__branches = []
        
    def add_branch(self, block, condition=ConstTrue()):
        self.__branches.append((condition, block))
        
    def render(self, scope):
        for cond, block in self.__branches:
            if cond.is_true(scope):
                return block.render(scope)
        return []    